/**
 *
 * Copyright 2011 TeleNav, Inc. All rights reserved.
 * MenuHandler.java
 *
 */
package com.palmwindActivity.app.main;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.view.MenuItem;

import com.palmwindActivity.nav.local.LocalThumbnailActivity;
import com.palmwindActivity.nav.remote.RemoteThumbnailActivity;
import com.palmwindActivity.settings.SettingActivity;
import com.palmwindActivity.textmodule.TextReviewInput;

/**
 *@author Kane (gongchen.cn@gmail.com)
 *@date 2011-4-6
 */
public class MenuHandler implements MenuItem.OnMenuItemClickListener 
{
    public static final int EXIT_ID = 0X01;

    public static final int TEXT_ID = 0X02;
    
    public static final int NAV_LOCAL_ID = 0x03;
    
    public static final int NAV_REMOTE_ID = 0x04;
    
    public static final int SETTING_NETWORK_ID = 0x05;
    
    Activity activity;
    
    public MenuHandler(Activity activity)
    {
        this.activity = activity;
    }

    public boolean onMenuItemClick(MenuItem item)
    {
        if (EXIT_ID == item.getItemId())
        {
        	SharedPreferences preference = activity.getSharedPreferences("releaseall", 0);
        	Editor edit = preference.edit();
        	edit.putBoolean("isRelease", true);
        	edit.commit();
            System.out.println("name is : " + activity.getPackageName());
            activity.finish();
        }
        else if(TEXT_ID == item.getItemId())
        {
            Intent intent = new Intent();
            intent.setClass(activity, TextReviewInput.class);
            activity.startActivity(intent);
        }
        else if(NAV_LOCAL_ID == item.getItemId())
        {
        	Intent intent = new Intent();
        	intent.setClass(activity, LocalThumbnailActivity.class);
        	activity.startActivity(intent);
        }
        else if(NAV_REMOTE_ID == item.getItemId())
        {
        	Intent intent = new Intent();
        	intent.setClass(activity, RemoteThumbnailActivity.class);
        	activity.startActivity(intent);
        }
        else if(SETTING_NETWORK_ID == item.getItemId())
        {
        	Intent intent = new Intent();
        	intent.setClass(activity, SettingActivity.class);
        	activity.startActivity(intent);
        }
        return false;
    }
    
}